package com.itheima.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.admin.dto.ApSensitivePageRequestDto;
import com.itheima.admin.mapper.AdSensitiveMapper;
import com.itheima.admin.pojo.AdChannel;
import com.itheima.admin.pojo.AdSensitive;
import com.itheima.admin.service.AdSensitiveService;
import com.itheima.common.vo.PageResultVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class AdSensitiveServiceImpl extends ServiceImpl<AdSensitiveMapper, AdSensitive>implements AdSensitiveService {
    @Override
    public PageResultVo<AdSensitive> pageList(ApSensitivePageRequestDto dto) {
        //设置分页参数
        IPage<AdSensitive> pageInfo = new Page(dto.getPage(), dto.getSize());
        //构建查询条件
        LambdaQueryWrapper<AdSensitive> queryWrapper = new LambdaQueryWrapper<>();
        //查询敏感词--模糊查询
        queryWrapper.like(null != dto.getName(), AdSensitive::getSensitives,dto.getName());

        //分页查询
        IPage<AdSensitive> page = page(pageInfo, queryWrapper);

        return PageResultVo.pageResult(page.getCurrent(),
                page.getSize(),page.getTotal(),page.getRecords());
    }
}
